package org.dromara.system.service.impl;


import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class XcxLoginService {

    @Autowired
    private WxMaService wxMaService;

    public String getUserPhone(String code) {
        try {
            WxMaPhoneNumberInfo wxMaPhoneNumberInfo = wxMaService.getUserService().getPhoneNumber(code);
            return wxMaPhoneNumberInfo.getPurePhoneNumber();
        } catch (WxErrorException e) {
            throw new RuntimeException(e);
        }
    }
}
